package com.itheima.mapper;

import com.itheima.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;
public interface ClazzMapper {
//    @Select("select id,name,room,begin_date,end_date,master_id,subject,create_time,update_time from clazz")
//    public List<Clazz> findAll();
    List<Clazz> list(ClazzQueryParam clazzQueryParam);
    /**
     * 查询所有班级
     */
    @Select("select id,name,room,begin_date as beginDate,end_date as endDate,master_id as masterId,subject,create_time as createTime,update_time as updateTime from clazz order by create_time desc")
    List<Clazz> listAll();
    @Delete("delete from clazz where id = #{id}" )
    public void deleteById(Integer id);

    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    public void save(Clazz clazz);

    @Select("select id,name,room,begin_date,end_date,master_id,subject,create_time,update_time from clazz where id = #{id}")
    Clazz getById(Integer id);

    @Update("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{andDate},master_id = #{masterId},subject=#{subject},update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);

}
